#!/bin/sh

setTheJgmenu()
{
    if [ -d "/usr/share/icons/boxOS" ] 
    then
        echo "Jump"
    else
        sudo mkdir /usr/share/icons/boxOS
        sudo cp /usr/lib/box_envirment/icons/timg.png /usr/share/icons/boxOS/rab.png
        sudo cp -f /usr/lib/box_envirment/tint2/tint2rc /etc/xdg/tint2
    fi

    
    if [ -d "/etc/xdg/jgmenu" ] 
    then
        echo "jump"
    else
        sudo mkdir -p /etc/xdg/jgmenu
        sudo cp /usr/lib/box_envirment/jgmenu/* /etc/xdg/jgmenu
    fi
}

# cp the config File to the correct dict
cpConfigFile()
{
    #cp the openbox config file
    sudo cp -f /usr/lib/box_envirment/openbox/* /etc/xdg/openbox/

    #set the jgmenu
    setTheJgmenu

    #cp the tint2 config file
    sudo cp -f /usr/lib/box_envirment/tint2/* /etc/xdg/tint2/

    #cp the lightdm config file
    sudo cp -f /usr/lib/box_envirment/lightdm/* /etc/lightdm/


    #cp the gtk config file
    sudo cp -f /usr/lib/box_envirment/gtk/* /etc/gtk-3.0/

}

cpTheWindowTheme()
{
    #cp the theme
    sudo cp -r /usr/lib/box_envirment/theme/Greybird/ /usr/share/themes 

}

runAndReboot()
{
    cpTheWindowTheme
    cpConfigFile
    setTheJgmenu

    #TODO: 判断配置文件是否已经拷贝成功
    echo "after 5 seconds the computer will reboot!"

    for t in 1 2 3 4 5
    do
        sleep 1
        echo $t
    done
    
    reboot
}

runAndReboot
